home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-12-09 | 6.7 KB | 191 lines | [TEXT/MPS ] |
- //------------------------------------------------------------------------------
- // UIconEdit.h - Class declarations for UIconEdit.cp
- //
- // Written by K.L. Colclasure for MacTutor, Dec 3, 1989
- // Copyright © 1989 MacTutor, all rights reserved.
- //------------------------------------------------------------------------------
-
- // This typedef makes it easier to declare Fields methods in
- // MPW C++:
- typedef pascal void (*FieldProcPtr) (StringPtr fieldName,
- Ptr fieldAddr, short fieldType, void *link);
-
- const OSType kFileType = 'IDOC';
- const OSType kSignature = 'ICED';
- const short kBorder = 8;
- const short kDefaultMagnification = 7;
-
- //------------------------------------------------------------------------------
- class TIconBitMap : public TObject {
- //------------------------------------------------------------------------------
- public:
- Handle fDataHandle; // Handle to the icon’s
- // bitmap.
-
- // Initialize the IconBitMap object and allocate space for
- // its data.
- virtual pascal void IIconBitMap (void);
- // Free the icon’s bit map.
- virtual pascal void Free (void);
- // Set the contents of the icon bit map to the new bit map.
- virtual pascal void SetIconBitMap (Handle theBitMap);
- // Clear the icon map by setting its bits to zero.
- virtual pascal void Clear (void);
- // Invert the icon’s bit map.
- virtual pascal void Invert (void);
- // Return the state of the given bit.
- virtual pascal Boolean GetBit (Point iconBit);
- // Set the state of the given bit as indicated.
- virtual pascal void SetBit (Point iconBit,
- Boolean turnBitOn);
- // Create a new icon object which is a copy of itself.
- virtual pascal TIconBitMap *Copy (void);
- // Copy icon data to an existing icon object.
- virtual pascal void CopyDataTo (TIconBitMap *anIcon);
- // Draw the icon’s bit map.
- virtual pascal void Draw (Rect *area);
- #if qInspector
- virtual pascal void Fields (FieldProcPtr DTF, void *link);
- #endif
- };
-
- //------------------------------------------------------------------------------
- class TIconDocument : public TDocument {
- //------------------------------------------------------------------------------
- public:
- TIconBitMap *fIconBitMap; // The document’s icon
- // object.
-
- // Initialize the document.
- virtual pascal void IIconDocument (void);
- // Sets the document’s data to represent a “new”
- // document.
- virtual pascal void DoInitialState (void);
- // Free allocated memory when the document is closed.
- virtual pascal void Free (void);
- // Create the window & view objects when a document’s
- // opened.
- virtual pascal void DoMakeViews (Boolean forPrinting);
- // Set the state of the menu items to which this class
- // responds.
- virtual pascal void DoSetupMenus (void);
- // Handle menu items specific to this class.
- virtual pascal TCommand *DoMenuCommand (
- CmdNumber whichCmd);
- // Invert the bits of this document’s icon and redraw its
- // views.
- virtual pascal void InvertIcon (void);
- #if qInspector
- virtual pascal void Fields (FieldProcPtr DTF, void *link);
- #endif
- };
-
- //------------------------------------------------------------------------------
- class TIconView : public TView {
- //------------------------------------------------------------------------------
- public:
- TIconDocument *fIconDocument; // View’s icon
- // document.
- short fMagnification; // Times to magnify
- // icon.
-
- // Initialize the view from a resource template.
- virtual pascal void IRes (TDocument *itsDocument,
- TView *itsSuperView, Ptr *itsParams);
- // Return the view’s minimum size.
- virtual pascal void CalcMinSize (VPoint *minSize);
- // Draw this view.
- virtual pascal void Draw (Rect *area);
- // Set the state of the menu items to which this class
- // responds.
- virtual pascal void DoSetupMenus (void);
- // Handle menu items specific to this class.
- virtual pascal TCommand *DoMenuCommand (
- CmdNumber whichCmd);
- // Set the view’s magnification.
- virtual pascal void SetMagnification (
- short newMagnification);
- // Handle mouse clicks in this view.
- virtual pascal TCommand *DoMouseCommand (
- Point *theMouse, EventInfo *info,
- Point *hysteresis);
- // Convert the given mouse point to an icon bit.
- virtual pascal Boolean PointToBit (Point thePoint,
- Point *iconBit);
- // Draw the given bit in the given state.
- virtual pascal void DrawBit (Point theBit,
- Boolean turnItOn);
- #if qInspector
- virtual pascal void Fields (FieldProcPtr DTF, void *link);
- #endif
- };
-
- //------------------------------------------------------------------------------
- class TDrawCommand : public TCommand {
- //------------------------------------------------------------------------------
- public:
- TIconDocument *fIconDocument; // Document
- // affected.
- TIconView *fIconView; // View affected.
- TIconBitMap *fIconBitMap; // Icon affected.
- Boolean fTurnBitsOn; // Turn bits on or off.
-
- // Initialize the command and associate it with a view.
- virtual pascal void IDrawCommand (
- TIconView *itsIconView);
- // Constrain the mouse to be within the icon in the edit
- // view.
- virtual pascal void TrackConstrain (VPoint *anchorPoint,
- VPoint *prevPoint, VPoint *nextPoint);
- // Overridden to avoid standard feedback.
- virtual pascal void TrackFeedback (VPoint *anchorPoint,
- VPoint *nextPoint, Boolean turnItOn,
- Boolean mouseMoved);
- // Track the mouse.
- virtual pascal TCommand *TrackMouse (
- TrackPhase aTrackPhase, VPoint *anchorPoint,
- VPoint *prevPoint, VPoint *nextPoint,
- Boolean mouseMoved);
- #if qInspector
- virtual pascal void Fields (FieldProcPtr DTF, void *link);
- #endif
- };
-
- //------------------------------------------------------------------------------
- class TInvertCommand : public TCommand {
- //------------------------------------------------------------------------------
- public:
- TIconDocument *fIconDocument; // Document
- // affected.
-
- // Initialize the command and associate it with a
- // document.
- virtual pascal void IInvertCommand (
- TIconDocument *itsIconDocument);
- // Implement the command by calling the document’s
- // Invert method.
- virtual pascal void DoIt (void);
- // Implement undo by calling the document’s Invert
- // method again.
- virtual pascal void UndoIt (void);
- // Implement redo by calling the document’s Invert
- // method yet again.
- virtual pascal void RedoIt (void);
- #if qInspector
- virtual pascal void Fields (FieldProcPtr DTF, void *link);
- #endif
- };
-
- //------------------------------------------------------------------------------
- class TIconApplication : public TApplication {
- //------------------------------------------------------------------------------
- public:
- // Initialize the application and globals.
- virtual pascal void IIconApplication (
- OSType iconFileType);
- // Create a document of type TIconDocument and return a
- // reference to it.
- virtual pascal TDocument *DoMakeDocument (
- CmdNumber itsCmdNumber);
- };
-